package com.robot.admin.client;

import com.robot.admin.client.impl.CouponClientImpl;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author lin
 */
@Component
@FeignClient(value = "robot-coupon", fallback = CouponClientImpl.class)
public interface CouponClient {
    /**
     * 传入对象来增加coupon
     *
     * @param coupon
     */
    @RequestMapping(value = "coupon/third/addCouponByCoupon", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    public void thirdAddCouponByCoupon(@RequestBody String coupon);

    /**
     * 传入对象来修改coupon
     *
     * @param coupon
     */
    @PutMapping(value = "coupon/third/updateCouponByCoupon", produces = "application/json; charset=utf-8")
    @Transactional(rollbackFor = Exception.class)
    public void thirdUpdateCouponByCoupon(@RequestBody String coupon);

    /**
     * 分页+多条件查询coupon
     *
     * @param searchMap 查询条件封装
     * @param page      页码
     * @param size      页大小
     * @return 分页结果
     */
    @RequestMapping(value = "coupon/third/findCouponsBySearch/{page}/{size}", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    public String thirdFindCouponsBySearch(@RequestBody Map searchMap, @PathVariable int page, @PathVariable int size);

    /**
     * 根据ID查找coupon
     *
     * @param id
     * @return
     */
    @GetMapping(value = "coupon/third/findCouponById/{id}", produces = "application/json; charset=utf-8")
    public String thirdFindCouponById(@PathVariable String id);
}
